package com.bjpowernode.springboot.service.impl;

import com.bjpowernode.springboot.domain.User;
import com.bjpowernode.springboot.mapper.UserMapper;
import com.bjpowernode.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * CreateTime：2020/9/1 21:07
 */

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List getUserList() {
        long l = userMapper.countByExample(null);
        System.out.println("总共有：" + l + "条记录");

        String id = "12345678";
        User user = userMapper.selectByPrimaryKey(id);
        System.out.println("通过id=" + id + "查询出的user：" + user);

        List<User> users = userMapper.selectByExample(null);
        System.out.println(users);

        User user1 = new User();
        user1.setName("师傅");
        user1.setId("123e4r7654");
        userMapper.insert(user1);

        return null;
    }

    @Override
    public void insertUser(User user) {
        userMapper.insert(user);
    }
}
